﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Data.SqlClient;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class roll : System.Web.UI.Page
{


    protected void Page_Load(object sender, EventArgs e)
    {
       
    }
    protected void btnfreeuser_Click(object sender, EventArgs e)
    {
        if ((Convert.ToInt32(Session["role"]) == 1))
        {
            Response.Write("<script>alert('Already you are free user')</script>");
        }
        else
        {
            using (var obj = new OnlineexamDataContext())
            {
                var ss = obj.tbllogins.Single(a => a.Id == (Convert.ToInt32(Session["UserId"])));
                ss.Fk_role_id = 1;
                obj.SubmitChanges();
                emptyfield();
            }
        }
    }

    private void emptyfield()
    {
        lblmsg.Text = "You have changed as a free user successfully please logout and login again to the changes get effected";
    }
    protected void btnpaiduser_Click(object sender, EventArgs e)
    {
        if ((Convert.ToInt32(Session["role"]) == 123))
        {
            Response.Write("<script>alert('Already you are paid user')</script>");
        }
        else
        {
            using (var obj = new OnlineexamDataContext())
            {
                var ss = obj.tbllogins.Single(a => a.Id == (Convert.ToInt32(Session["UserId"])));
                ss.Fk_role_id = 123;
                obj.SubmitChanges();
                emptypaid();
            }
        }
    }

    private void emptypaid()
    {
        lblmsg.Text = "You have changed as a paid user successfully please logout and login again to the changes get effected";
    }
    protected void btntutor_Click(object sender, EventArgs e)
    {
        if ((Convert.ToInt32(Session["role"]) == 12345))
        {
            Response.Write("<script>alert('Already you are Tutor user')</script>");
        }
        else
        {
            using (var obj = new OnlineexamDataContext())
            {
                var ss = obj.tbllogins.Single(a => a.Id == (Convert.ToInt32(Session["UserId"])));
                ss.Fk_role_id = 12345;
                obj.SubmitChanges();
                emptytutor();
            }
        }
    }

    private void emptytutor()
    {
        lblmsg.Text = "You have changed as a tutor user successfully please logout and login again to the changes get effected";
    }
    
}